package top.burning.confidant.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.burning.confidant.mapper.BookMapper;
import top.burning.confidant.mapper.UserMapper;
import top.burning.confidant.model.pojo.Book;
import top.burning.confidant.model.pojo.User;
import top.burning.confidant.service.BookService;

import java.util.Date;

@Service
public class BookServiceImpl implements BookService {
    @Autowired
    private BookMapper bookMapper;
    
    @Autowired
    private UserMapper userMapper;
    @Override
    public int addBook(Book book) {
        book.setState(1);
        book.setCreateTime(new Date());
        User user=new User();
        user.setUserId(book.getbUserId());
        book.setCreatePeople(userMapper.selectUserId(book.getbUserId()).getUserName());
        return bookMapper.insert(book);
    }


}